#define use _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool check(int x) {
    while(x) {
        int t = x % 10;
        if(t == 9) {
            return false;
        }
        x /= 10;
    }
    return true;
}
char s[20];
int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    int k = 0;
    if(x == 10) {
        while(y) {
            int t = y % 9;
            s[k++] = t + '0';
            y /= 9;
        }
        for(int i = k - 1; i >= 0; i--) {
            printf("%c", s[i]);
        }
    }else if(x == 9){
        if(!check(y)) {
            printf("DATA ERROR!\n");
            return 0;
        }
        int temp = 0;
        int k = 1;
        while(y) {
            int t = y % 10;
            temp += t * k;
            k *= 9;
            y /= 10;
        }
        printf("%d", temp);
    }else {
        printf("DATA ERROR!\n");
    }
    return 0;
}

